package com.cskaoyan.catmall.config;

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.stereotype.Component;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * 创建日期: 2022-01-12-15-38
 * author : LL
 * description:
 */
@Component
public class ShiroWxuserSessionManager extends DefaultWebSessionManager {
    //根据特定的请求头拿到对应的sessionid信息
    private static String Authen_Token = "X-CskaoyanMarket-Token";

    @Override
    protected Serializable getSessionId(ServletRequest req, ServletResponse resp) {
        HttpServletRequest request = (HttpServletRequest) req;
        String sessionId = request.getHeader(Authen_Token);
        if (sessionId != null && !"".equals(sessionId)) {
            return sessionId;
        }
        return super.getSessionId(req, resp);
    }
}